package com.rabbitmq.route;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author lipengwei
 */
@Component
public class RouteCustomer {

    @RabbitListener(bindings = {
            @QueueBinding(
                    // 创建临时队列
                    value = @Queue,
                    // 自定义交换机，名称和类型
                    exchange = @Exchange(value = "directs", type = "direct"),
                    key = {"info","error", "warn"}
            )
    })
    public void receivel(String message) {
        System.out.println("message = " + message);
    }


    @RabbitListener(bindings = {
            @QueueBinding(
                    // 创建临时队列
                    value = @Queue,
                    // 自定义交换机，名称和类型
                    exchange = @Exchange(value = "directs", type = "direct"),
                    key = {"warn"}
            )
    })
    public void receivel2(String message) {
        System.out.println("message2 = " + message);
    }
}
